<!DOCTYPE HTML>
<html>

<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>通过使用 epplus 来动态生成 excel 表单 | DeepThought</title>
  <meta name="google-site-verification" content="Ei6mmDdf-cJwox1RvJOeX8Dc720fqWjZQu-Ww2BjBt4">
  
  <meta name="author" content="积慕">
  
  <meta name="description" content="通过使用epplus来创建，生成，构建 excel 表单">
  
  
  <meta name="keywords" content="epplus,epplus.core,excel,spreadsheet,表单,电子表格,epplus excel,生成表单,生成excel,动态生成excel,动态生成表单,.NET EXCEL,.NET生成excel,.NET EPPLUS,c# epplus,c# excel,c#生成表单,c#创建excel,.NET创建excel,epplus 使用,epplus 教程,epplus 经验,epplus 指南,epplus guide,epplus tutorial,epplus 使用,epplus use,epplus usage,如何使用epplus,how epplus">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
  <meta property="og:title" content="通过使用 epplus 来动态生成 excel 表单">
  <meta property="og:site_name" content="DeepThought">

  
  <meta property="og:image" content>
  

  <link href="https://pic.zhuliang.ltd/favicon.ico" rel="shortcut icon" type="image/x-icon">
  <link rel="alternate" href="/atom.xml" title="DeepThought" type="application/atom+xml">
  <link rel="stylesheet" href="/css/style.css" media="screen" type="text/css">

  <link rel="stylesheet" href="//at.alicdn.com/t/font_1187293_8fec2ou5fyx.css">

  <!-- <link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/9.6.0/styles/github.min.css"> -->
  <!-- <script src="//cdn.bootcss.com/highlight.js/9.6.0/highlight.min.js"></script> -->
  <script src="/js/highlight.min.js"></script>

  <link rel="stylesheet" href="/css/markdown.css">

  <script src="/js/av-min.3.0.4.js"></script>
  <script src="/js/Valine.min.1.3.6.js"></script>

</head></html>

<body>
  <header id="header" class="inner"><div class="alignleft">
  <h1><a href="/">DeepThought</a></h1>
  <h2><a href="/">知识需沉淀，更需分享</a></h2>
</div>
<nav id="main-nav" class="alignright">
  <ul>
    
      <li><a href="/">首页</a></li>
    
      <li><a href="/about">关于我</a></li>
    
      <li><a href="/atom.xml">订阅RSS</a></li>
    
  </ul>
  <div class="clearfix"></div>
</nav>
<div class="clearfix"></div>
        </header>
  <div id="content" class="inner">
    <div id="main-col" class="alignleft"><div id="wrapper"><article class="post">
  
  <div class="post-content">
    <header>
      
        <div class="icon"></div>
      

 
      
  
    <h1 class="title">通过使用 epplus 来动态生成 excel 表单</h1>
  


      
        <time datetime="2020-11-18T12:15:43.000Z">
          create: 2020-11-18 20:15:43 | update: 2020-11-18 20:15:43
            <span style="float: right;">
    <span class="post-count" id="busuanzi_container_page_pv" style="display: inline;">
        
        本文总阅读量: <span id="busuanzi_value_page_pv"></span>&nbsp;次
        <span class="blueSeparate">&nbsp;|&nbsp;</span>
        
        <span class="post-count">文章总字数:&nbsp;2k&nbsp;字</span>
    <span class="blueSeparate">&nbsp;|&nbsp;</span>
    <span class="post-count">阅读约需:&nbsp;9&nbsp;分钟</span>
    <br>
</span>
</span>
        </time>
      
            
    </header>
    <div class="entry">
      
      <p>Summary:</p>
<ul>
<li>本文旨在说明通过建立本地模型类，通过 EPPlus，来统一生成 excel，模型类见下方代码块。<ul>
<li>适合需要动态生成整个 excel 表单的业务。</li>
<li>如果无需动态生成，则可以直接给出<code>物理excel文件</code>硬编码即可。</li>
</ul>
</li>
<li>因涉及到公司业务，这里仅给出和业务无关部分代码。</li>
</ul>
<p>环境说明：</p>
<ul>
<li>VS 2019</li>
<li><p><a href="https://github.com/VahidN/EPPlus.Core" target="_blank" rel="noopener">EPPLUS.CORE.DLL@1.5.4</a></p>
<a id="more"></a>
<h1 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h1><p>DownLoadExcel api<br></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">[HttpGet]
[Route(&quot;DownloadSpreadSheet/{dataId}&quot;)]
[Authorize]
public async Task&lt;IActionResult&gt; DownloadSpreadSheet([Required] int dataId)
{
 //格式化后的数据，行列均在结果集合中，模型见下方 `ExcelDataVO`
 var excelDataList = await _someService_.GetFormatedSpreadSheetDataList(id);

 using (var excel = new ExcelPackage())
 {
     var sheet = excel.Workbook.Worksheets.Add(&quot;YOUR WORK SHEET NAME&quot;);

     foreach (var excelData in excelDataList)
     {
         var currentCell = sheet.Cells[excelData.Row, excelData.Column];
         currentCell.Value = excelData.IsHeaderRow
                                                                 ? excelData.HeaderName
                                                                 : excelData.Value;
         if (excelData.IsMergeCells)
         {
             //合并单元格
             sheet.Cells[excelData.Row, excelData.MergeCellColumnFromTo.Key, excelData.Row, excelData.MergeCellColumnFromTo.Value].Merge = true;
         }

         if (excelData.CellStyle.IsSetStyle)
         {
             if (excelData.CellStyle.BackgroundColor != Color.Empty)
             {
                 //设置单元格背景色的话，需要先设置 PatternType，否则会提示错误。
                 currentCell.Style.Fill.PatternType = ExcelFillStyle.Solid;
                 currentCell.Style.Fill.BackgroundColor.SetColor(excelData.CellStyle.BackgroundColor);
             }
             if (excelData.CellStyle.Width &gt; 0)
             {
                 //设置列的宽度：需要说明的是 EPPLUS 的自适配指的内容适配列的宽度，而不是列宽适配内容宽度。
                 sheet.Column(excelData.Column).Width = excelData.CellStyle.Width;
             }
             if (excelData.CellStyle.IsJustifyCenter)
             {
                 //单元格内容居中
                 currentCell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
             }
         }
     }
     var lastHeaderColumn = excelDataList.Where(ent =&gt; ent.IsHeaderRow).OrderBy(ent =&gt; ent.Column).LastOrDefault();

     //需要注意下，`自动过滤`功能无法针对单个单元格来进行设置（单独设置的话，仅对最后一个单元格有效），这里需要通过指定行列的方式来设置单元格自动过滤。
     sheet.Cells[lastHeaderColumn.Row, 1, lastHeaderColumn.Row, lastHeaderColumn.Column].AutoFilter = true;

     byte[] fileBytes = excel.GetAsByteArray();
     return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet,  &quot;EXCEL_NAME.xlsx&quot;);
 }
}
</code></pre>
</li>
</ul>
<p>ExcelDataVO.cs</p>
<p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">public class ExcelDataVO
{
    public int Row { get; set; }

    public int Column { get; set; }

    public string HeaderName { get; set; }

    public string ParentHeaderName { get; set; }
    public string ParentValue { get; set; }

    public string Value { get; set; }

    public bool IsMergeCells { get; set; }

    public string RawDataProp { get; set; }

    /// &lt;summary&gt;
    /// key= column number starting from, value=column number ending to
    /// &lt;/summary&gt;
    public KeyValuePair&lt;int, int&gt; MergeCellColumnFromTo { get; set; }

    public bool IsHeaderRow { get; set; }

    public FlowPlanExcelCellType FlowPlanExcelCellType { get; set; }

    public ExcelCellStyleVO CellStyle { get; set; }
}
</code></pre>
<p>FlowPlanExcelCellType.cs</p>
<p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">public enum FlowPlanExcelCellType
{
    Normal = 0,
    Wave = 1,
    AutoCalculate = 2
}
</code></pre>
<p>ExcelCellStyleVO.cs</p>
<p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">public struct ExcelCellStyleVO
{
    public ExcelCellStyleVO(Color backgroundColor, string widthStr, bool isJustifyCenter = false)
    {
        BackgroundColor = backgroundColor;
        Double.TryParse(widthStr?.Replace(&quot;px&quot;, string.Empty, StringComparison.OrdinalIgnoreCase).Trim(), out var width);
        Width = width / 10; // ratio:convert  px(used in FPlan) to widh(used in excel)
        IsJustifyCenter = isJustifyCenter;
        IsSetStyle = true;
    }

    /// &lt;summary&gt;
    /// 
    /// &lt;/summary&gt;
    public Color BackgroundColor { get; set; }

    public double Width { get; set; }

    public bool IsSetStyle { get; private set; }

    public bool IsJustifyCenter { get; set; }
}
</code></pre>
<h1 id="EPPLUS-的一些额外设置"><a href="#EPPLUS-的一些额外设置" class="headerlink" title="EPPLUS 的一些额外设置"></a>EPPLUS 的一些额外设置</h1><h2 id="保存到本地磁盘位置"><a href="#保存到本地磁盘位置" class="headerlink" title="保存到本地磁盘位置"></a>保存到本地磁盘位置</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">FileInfo newFile = new FileInfo(@&quot;x:\test.xlsx&quot;);
if(newFile.Exists)
{
   newFile.Delete();
   newFile = new FileInfo(@&quot;x:\test.xlsx&quot;);
}
using(ExcelPackage package=new ExcelPackage(new FileInfo(@&quot;X:\test.xlsx&quot;)))
{
    var worksheet = package.Workbook.Worksheets.Add(&quot;sheet_1&quot;);//创建worksheet
    package.Save();//保存excel
}
</code></pre>
<h2 id="添加数据"><a href="#添加数据" class="headerlink" title="添加数据"></a>添加数据</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">worksheet.Cells[1, 1].Value = &quot;名称&quot;;//通过指定行列数
worksheet.Cells[&quot;A1&quot;].Value = &quot;名称&quot;;//通过指定单元格名
</code></pre>
<h2 id="使用公式"><a href="#使用公式" class="headerlink" title="使用公式"></a>使用公式</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">worksheet.Cells[&quot;D2:D5&quot;].Formula = &quot;B2*C2&quot;;//这是乘法的公式，意思是第二列乘以第三列的值赋值给第四列，这种方法比较简单明了
worksheet.Cells[6, 2, 6, 4].Formula = string.Format(&quot;SUBTOTAL(9,{0})&quot;, new ExcelAddress(2, 2, 5, 2).Address);//这是自动求和的方法，至于subtotal的用法你需要自己去了解了
</code></pre>
<h2 id="设置样式"><a href="#设置样式" class="headerlink" title="设置样式"></a>设置样式</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//设置单元格格式
worksheet.Cells[5, 3].Style.Numberformat.Format = &quot;#,##0.00&quot;;//这是保留两位小数

//设置对齐方式
worksheet.Cells[1, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;//水平居中
worksheet.Cells[1, 1].Style.VerticalAlignment = ExcelVerticalAlignment.Center;//垂直居中
worksheet.Cells[1, 4, 1, 5].Merge = true;//合并单元格
worksheet.Cells.Style.WrapText = true;//自动换行

//设置单元格字体样式
worksheet.Cells[1, 1].Style.Font.Bold = true;//字体为粗体
worksheet.Cells[1, 1].Style.Font.Color.SetColor(Color.White);//字体颜色
worksheet.Cells[1, 1].Style.Font.Name = &quot;微软雅黑&quot;;//字体
worksheet.Cells[1, 1].Style.Font.Size = 12;//字体大小

//设置单元格背景样式
worksheet.Cells[1, 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[1, 1].Style.Fill.BackgroundColor.SetColor(Color.FromArgb(128, 128, 128));//设置单元格背景色

//设置单元格边框，两种方法
worksheet.Cells[1, 1].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.FromArgb(191, 191, 191));//设置单元格所有边框
worksheet.Cells[1, 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;//单独设置单元格底部边框样式和颜色（上下左右均可分开设置）
worksheet.Cells[1, 1].Style.Border.Bottom.Color.SetColor(Color.FromArgb(191, 191, 191));

//设置单元格的行高和列宽
worksheet.Cells.Style.ShrinkToFit = true;//单元格自动适应大小
worksheet.Row(1).Height = 15;//设置行高
worksheet.Row(1).CustomHeight = true;//自动调整行高
worksheet.Column(1).Width = 15;//设置列宽

//设置sheet背景
worksheet.View.ShowGridLines = false;//去掉sheet的网格线
worksheet.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells.Style.Fill.BackgroundColor.SetColor(Color.LightGray);//设置背景色
worksheet.BackgroundImage.Image = Image.FromFile(@&quot;firstbg.jpg&quot;);//设置背景图片
</code></pre>
<h2 id="插入图片和形状"><a href="#插入图片和形状" class="headerlink" title="插入图片和形状"></a>插入图片和形状</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//插入图片
ExcelPicture picture = worksheet.Drawings.AddPicture(&quot;logo&quot;, Image.FromFile(@&quot;firstbg.jpg&quot;));//插入图片
picture.SetPosition(100, 100);//设置图片的位置
picture.SetSize(100, 100);//设置图片的大小


//插入形状
ExcelShape shape = worksheet.Drawings.AddShape(&quot;shape&quot;, eShapeStyle.Rect);//插入形状
shape.Font.Color = Color.Red;//设置形状的字体颜色
shape.Font.Size = 15;//字体大小
shape.Font.Bold = true;//字体粗细
shape.Fill.Style = eFillStyle.NoFill;//设置形状的填充样式
shape.Border.Fill.Style = eFillStyle.NoFill;//边框样式
shape.SetPosition(200, 300);//形状的位置
shape.SetSize(80, 30);//形状的大小
shape.Text = &quot;test&quot;;//形状的内容
</code></pre>
<h2 id="添加超链接"><a href="#添加超链接" class="headerlink" title="添加超链接"></a>添加超链接</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//给图片加超链接
ExcelPicture picture = worksheet.Drawings.AddPicture(&quot;logo&quot;, Image.FromFile(@&quot;firstbg.jpg&quot;), new ExcelHyperLink(&quot;http:\\www.baidu.com&quot;, UriKind.Relative));

//给单元格加超链接
worksheet.Cells[1, 1].Hyperlink = new ExcelHyperLink(&quot;http:\\www.baidu.com&quot;, UriKind.Relative);
</code></pre>
<h2 id="隐藏sheet"><a href="#隐藏sheet" class="headerlink" title="隐藏sheet"></a>隐藏sheet</h2><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">worksheet.Hidden = eWorkSheetHidden.Hidden;//隐藏sheet
worksheet.Column(1).Hidden = true;//隐藏某一列
worksheet.Row(1).Hidden = true;//隐藏某一行
</code></pre>
<h1 id="图标设置"><a href="#图标设置" class="headerlink" title="图标设置"></a>图标设置</h1><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//创建图表
ExcelChart chart = worksheet.Drawings.AddChart(&quot;chart&quot;, eChartType.ColumnClustered);//eChartType中可以选择图表类型

//选择数据
//chart.Series.Add()方法所需参数为：chart.Series.Add(Y轴数据区,X轴数据区) 
ExcelChartSerie serie = chart.Series.Add(worksheet.Cells[2, 3, 5, 3], worksheet.Cells[2, 1, 5, 1]);//设置图表的x轴和y轴
serie.HeaderAddress = worksheet.Cells[1, 3];//设置图表的图例

//设置图标样式
chart.SetPosition(150, 10);//设置位置
chart.SetSize(500, 300);//设置大小
chart.Title.Text = &quot;销量走势&quot;;//设置图表的标题
chart.Title.Font.Color = Color.FromArgb(89, 89, 89);//设置标题的颜色
chart.Title.Font.Size = 15;//标题的大小
chart.Title.Font.Bold = true;//标题的粗体
chart.Style = eChartStyle.Style15;//设置图表的样式
chart.Legend.Border.LineStyle = eLineStyle.Solid;
chart.Legend.Border.Fill.Color = Color.FromArgb(217, 217, 217);//设置图例的样式
</code></pre>
<h1 id="嵌入VBA代码"><a href="#嵌入VBA代码" class="headerlink" title="嵌入VBA代码"></a>嵌入VBA代码</h1><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//首先将vba代码保存成txt文本格式，然后用epplus去调用这个txt文本文件即可
worksheet.CodeModule.Name = &quot;sheet&quot; ;
worksheet.CodeModule.Code = File.ReadAllText(@&quot;VBA-Code\vba.txt&quot;), Encoding.Default);
</code></pre>
<h1 id="Excel加密和锁定"><a href="#Excel加密和锁定" class="headerlink" title="Excel加密和锁定"></a>Excel加密和锁定</h1><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">worksheet.Protection.IsProtected = true;//设置是否进行锁定
worksheet.Protection.SetPassword(&quot;yk&quot;);//设置密码
worksheet.Protection.AllowAutoFilter = false;//下面是一些锁定时权限的设置
worksheet.Protection.AllowDeleteColumns = false;
worksheet.Protection.AllowDeleteRows = false;
worksheet.Protection.AllowEditScenarios = false;
worksheet.Protection.AllowEditObject = false;
worksheet.Protection.AllowFormatCells = false;
worksheet.Protection.AllowFormatColumns = false;
worksheet.Protection.AllowFormatRows = false;
worksheet.Protection.AllowInsertColumns = false;
worksheet.Protection.AllowInsertHyperlinks = false;
worksheet.Protection.AllowInsertRows = false;
worksheet.Protection.AllowPivotTables = false;
worksheet.Protection.AllowSelectLockedCells = false;
worksheet.Protection.AllowSelectUnlockedCells = false;
worksheet.Protection.AllowSort = false;
</code></pre>
<h1 id="Excel本身的一些属性设置"><a href="#Excel本身的一些属性设置" class="headerlink" title="Excel本身的一些属性设置"></a>Excel本身的一些属性设置</h1><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">epk.Workbook.Properties.Title = &quot;inventory&quot;;//设置excel的标题
epk.Workbook.Properties.Author = &quot;mei&quot;;//作者
epk.Workbook.Properties.Comments = &quot;this is a test&quot;;//备注
epk.Workbook.Properties.Company = &quot;ABC&quot;;//公司
</code></pre>
<h1 id="下拉框"><a href="#下拉框" class="headerlink" title="下拉框"></a>下拉框</h1><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//设置下拉框时首先需要设置下拉框显示的数据区域块并将其命名。
var val = worksheet.DataValidations.AddListValidation(worksheet.Cells[7, 8].Address);//设置下拉框显示的数据区域
val.Formula.ExcelFormula = &quot;=parameter&quot;;//数据区域的名称
val.Prompt = &quot;下拉选择参数&quot;;//下拉提示
val.ShowInputMessage = true;//显示提示内容
</code></pre>
<h1 id="冻结单元格"><a href="#冻结单元格" class="headerlink" title="冻结单元格"></a>冻结单元格</h1><p></p><p class="code-caption" data-lang="csharp" data-line_number="backend" data-trim_indent="backend" data-label_position="outer" data-labels_left="Code" data-labels_right=":" data-labels_copy="Copy Code"><span class="code-caption-label"></span></p><p></p>
<pre><code class="csharp">//冻结行的下一行，列设置为1，否则会冻结行*列导致无法滚动 x 轴
sheet.View.FreezePanes(headerRowIndex + 1, 1);
</code></pre>
<blockquote>
<p>参考信息：<a href="https://www.cnblogs.com/rumeng/p/3785748.html" target="_blank" rel="noopener">https://www.cnblogs.com/rumeng/p/3785748.html</a></p>
</blockquote>

      

      <div>
        
        <div style="background-color: rgb(255, 23, 0);user-select: auto;height: 3px;width:100%;margin-top: 40px;margin-bottom:15px;"></div>

<!-- <p>常言道：学然后知不足，教然后知困。</p>
<p>我知道你的焦虑，一起共进加油：P</p>
<p>关不关注都无所谓，会根据生活节奏紧凑度定期分享些开发经验、搬砖生涯、痛点、感悟。</p>
<p>
        <img src="https://pic.zhuliang.ltd/20191213133908.gif" alt="欢迎关注我的订阅号：P" />
</p> -->
<ul class="post-copyright" style="margin-left:0px;">
    <li class="post-copyright-author">
        <strong>本文作者：</strong>积慕
    </li>
    <li class="post-copyright-link">
        <strong>本文链接：</strong>
        <a href="/2020/11/backend/using-epplus-to-create-excel.html" title="通过使用 epplus 来动态生成 excel 表单">https://blog.zhuliang.ltd/2020/11/backend/using-epplus-to-create-excel.html</a>
    </li>
    <li class="post-copyright-license">
        <strong>版权： </strong>
        本站文章均采用 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" rel="external nofollow"
            target="_blank">CC BY-NC-SA 3.0 CN</a> 许可协议，请勿用于商业，转载注明出处！
    </li>
</ul>
        
      </div>
    </div>

    <footer>
      
      
  
  <div class="categories">
    <a href="/categories/backend/">backend</a>
  </div>

      
  
  <div class="tags">
    <a href="/tags/net-core/">.net core</a>
  </div>

      <!-- 
  <div class="addthis addthis_toolbox addthis_default_style">
    
    
      <a class="addthis_button_tweet"></a>
    
    
      <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
    
    
      <a class="addthis_button_pinterest_pinit" pi:pinit:layout="horizontal"></a>
    
    <a class="addthis_counter addthis_pill_style"></a>
  </div>
  <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script>
 -->
      
      <div class="clearfix"></div>
    </footer>
  </div>
</article>

<!-- 
<section id="comment">
  <h1 class="title">留言</h1>

  <div id="vcomments" style="background-color: #fff"></div>
  <script>
    new Valine({
      el: '#vcomments',
      appId: 'aTPKmG6tjDo3CbIXzAPzrj4X-gzGzoHsz',
      appKey: 'hNgWFneNpEcMnBJclPQnDgsd',
      notify: true,
      verify: true, //验证码
      avatar: 'monsterid', //https://valine.js.org/avatar.html
      placeholder: '请输入你的评论'
    })
  </script>
</section>
 --> <!--启用/关闭 LeanCloud 评论--></div></div>
    <aside id="sidebar" class="alignright">
  
<div class="widget tag">
  <h3 class="title"><i class="iconfont icon-category"></i>&nbsp;&nbsp;分类</h3>
  <ul class="entry">
  
    <li><a href="/categories/Obsidian/">Obsidian</a><small>1</small></li>
  
    <li><a href="/categories/PowerUser/">PowerUser</a><small>4</small></li>
  
    <li><a href="/categories/backend/">backend</a><small>57</small></li>
  
    <li><a href="/categories/frontend/">frontend</a><small>9</small></li>
  
    <li><a href="/categories/operations/">operations</a><small>5</small></li>
  
    <li><a href="/categories/提前退休/">提前退休</a><small>2</small></li>
  
  </ul>
</div>


  
<div class="widget tag">
  <h3 class="title"><i class="iconfont icon-new3"></i>&nbsp;&nbsp;最新文章</h3>
  <ul class="entry">
    
      <li>
        <a href="/2024/11/PowerUser/install-docker-in-pve-lxc.html">1. 通过 PVE LXC 搭建 docker 环境</a>
      </li>
    
      <li>
        <a href="/2024/11/Obsidian/obsidian-render-pie-chart.html">2. 2 套用于 obsidian 的生成时间占用饼图脚本示例，基于 templater， charts，echarts+dataview</a>
      </li>
    
      <li>
        <a href="/2024/10/PowerUser/fix-ios18-samba-readonly-issue.html">3. 解决 ios 18（包括ipadOS 18） 下通过文件(files app)连接 samba 服务器，目录变成只读权限的问题</a>
      </li>
    
      <li>
        <a href="/2023/07/operations/how-to-use-pm2.html">4. PM2 的安装、配置和使用</a>
      </li>
    
      <li>
        <a href="/2023/07/backend/expose-intranet-netcoreapi-to-internet.html">5. 通过 DDNS+显性URL 把内网部署的.NET CORE WEBAPI 项目暴露到公网中</a>
      </li>
    
  </ul>
</div>


  
<div class="widget tag">
  <h3 class="title"><i class="iconfont icon-tag"></i>&nbsp;&nbsp;标签</h3>
  <ul class="entry">
  
    <li><a href="/tags/net-core/">.net core</a><small>12</small></li>
  
    <li><a href="/tags/Debian/">Debian</a><small>2</small></li>
  
    <li><a href="/tags/Docker/">Docker</a><small>1</small></li>
  
    <li><a href="/tags/Elasticsearch/">Elasticsearch</a><small>35</small></li>
  
    <li><a href="/tags/Elasticsearch-Nest系列/">Elasticsearch.Nest系列</a><small>35</small></li>
  
    <li><a href="/tags/Obsidian/">Obsidian</a><small>1</small></li>
  
    <li><a href="/tags/PVE/">PVE</a><small>2</small></li>
  
    <li><a href="/tags/StackExchange-Redis系列/">StackExchange.Redis系列</a><small>12</small></li>
  
    <li><a href="/tags/centos/">centos</a><small>3</small></li>
  
    <li><a href="/tags/flex/">flex</a><small>1</small></li>
  
    <li><a href="/tags/ios/">ios</a><small>1</small></li>
  
    <li><a href="/tags/javascript/">javascript</a><small>1</small></li>
  
    <li><a href="/tags/linux/">linux</a><small>4</small></li>
  
    <li><a href="/tags/nginx/">nginx</a><small>2</small></li>
  
    <li><a href="/tags/nuget/">nuget</a><small>2</small></li>
  
    <li><a href="/tags/react/">react</a><small>6</small></li>
  
    <li><a href="/tags/styled-components/">styled-components</a><small>1</small></li>
  
    <li><a href="/tags/内网穿透/">内网穿透</a><small>4</small></li>
  
    <li><a href="/tags/培训讲义/">培训讲义</a><small>2</small></li>
  
    <li><a href="/tags/基础知识/">基础知识</a><small>2</small></li>
  
    <li><a href="/tags/性能优化/">性能优化</a><small>2</small></li>
  
    <li><a href="/tags/教程/">教程</a><small>64</small></li>
  
    <li><a href="/tags/理财/">理财</a><small>2</small></li>
  
    <li><a href="/tags/生命周期/">生命周期</a><small>1</small></li>
  
    <li><a href="/tags/经验/">经验</a><small>4</small></li>
  
  </ul>
</div>


  
  <script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
  <script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
  <div class="widget tag">
    <h3 class="title"><i class="iconfont icon-cloud1"></i>&nbsp;&nbsp;标签云</h3>
    <div id="myCanvasContainer" class="widget tagcloud">
      <canvas width="250" height="250" id="resCanvas" style="width:100%">
        <a href="/tags/net-core/" style="font-size: 17.14px;">.net core</a> <a href="/tags/Debian/" style="font-size: 11.43px;">Debian</a> <a href="/tags/Docker/" style="font-size: 10px;">Docker</a> <a href="/tags/Elasticsearch/" style="font-size: 18.57px;">Elasticsearch</a> <a href="/tags/Elasticsearch-Nest系列/" style="font-size: 18.57px;">Elasticsearch.Nest系列</a> <a href="/tags/Obsidian/" style="font-size: 10px;">Obsidian</a> <a href="/tags/PVE/" style="font-size: 11.43px;">PVE</a> <a href="/tags/StackExchange-Redis系列/" style="font-size: 17.14px;">StackExchange.Redis系列</a> <a href="/tags/centos/" style="font-size: 12.86px;">centos</a> <a href="/tags/flex/" style="font-size: 10px;">flex</a> <a href="/tags/ios/" style="font-size: 10px;">ios</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/linux/" style="font-size: 14.29px;">linux</a> <a href="/tags/nginx/" style="font-size: 11.43px;">nginx</a> <a href="/tags/nuget/" style="font-size: 11.43px;">nuget</a> <a href="/tags/react/" style="font-size: 15.71px;">react</a> <a href="/tags/styled-components/" style="font-size: 10px;">styled-components</a> <a href="/tags/内网穿透/" style="font-size: 14.29px;">内网穿透</a> <a href="/tags/培训讲义/" style="font-size: 11.43px;">培训讲义</a> <a href="/tags/基础知识/" style="font-size: 11.43px;">基础知识</a> <a href="/tags/性能优化/" style="font-size: 11.43px;">性能优化</a> <a href="/tags/教程/" style="font-size: 20px;">教程</a> <a href="/tags/理财/" style="font-size: 11.43px;">理财</a> <a href="/tags/生命周期/" style="font-size: 10px;">生命周期</a> <a href="/tags/经验/" style="font-size: 14.29px;">经验</a>
      </canvas>
    </div>
  </div>




</aside>
    <div class="clearfix"></div>
  </div>
  <footer id="footer" class="inner"><div class="alignleft">

  
  &copy; 2018 - 2024 &nbsp;<a href='/about'>积慕</a>
  
  &nbsp;&nbsp;<a href='https://www.cnblogs.com/deepthought/'>我的博客园地址</a>
  &nbsp;&nbsp;finalclassic#outlook.com
</div>

<div class="clearfix"></div>
<div>
  本站主题基于：<a href='https://github.com/hexojs/hexo-theme-light' rel="external nofollow">hexo-theme-light</a>
</div>
<div id="busuanzi_container_site_pv">
  本站总访问量&nbsp;<span id="busuanzi_value_site_pv"></span>&nbsp;次
</div>
<div style="width:300px;margin:0 auto; padding:20px 0;">
  <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31011702004805" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
    <img src="https://pic.zhuliang.ltd/20200102164648.png" style="float:left;"><p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">沪公网安备 31011702004805号</p></a>
</div></footer>
  <script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>




<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
(function($){
  $('.fancybox').fancybox();
})(jQuery);
</script>


<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>

<!-- <script src="/js/busuanzi.pure.mini.js"></script> -->
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?ea793b9c8d6b31df666a6bc15038e246";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        }
        else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>
</body>
</html>
